from django.utils.deprecation import MiddlewareMixin
from django.http import JsonResponse
class IsPathTokenMiddleware(MiddlewareMixin):

    def process_request(self,request):
        path_list = ['/app02/home/','/user/cart/'] # 路由的白名单
        current_path = request.path_info  # 当前 访问的路由信息
        token = request.GET.get('token')
        if current_path in path_list:
            # 如果当前访问路由在路由列表中，判断token
            if not token:
                return JsonResponse({'msg':'请先登录','code':400})
